package com.combetter.changxing.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;

import com.combetter.changxing.db.entity.Collect;

import java.util.List;

/**
 * 类名  ElectronicPipe
 * 作者  tlfx: Sean.guo
 * 日期  2019/4/15 10:21
 */
@Dao
public interface CollectDao {
    /**
     * 查询所有收藏信息
     *
     * @return
     */
    @Query("SELECT * FROM collect_table")
    List<Collect> getCollectInfoList();

    @Query("SELECT * FROM collect_table WHERE _uid = :uid")
    List<Collect> findCollectByUid(String uid);


    @Query("SELECT *  FROM collect_table WHERE _currentSelect = :select")
    Collect findCollect(int select);

    /**
     * 添加收藏
     *
     * @param collects
     * @return
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertSingle(Collect... collects);

    /**
     * 添加收藏
     *
     * @param collects
     * @return
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<Collect> collects);

    //根据名字删除
    @Query("DELETE  FROM collect_table where _uid=:uid")
    void deleteCollectByMac(String uid);

    @Query("DELETE  FROM collect_table")
    void deleteAll();

}
